#include "Audio.h"
#include "SimpleAudioEngine.h"
Audio* Audio::m_instance = nullptr;
Audio* Audio::getInstance(){
	if(m_instance == nullptr){
		m_instance = new Audio();
	}
	return m_instance;
}

void Audio::playBGM(){
	CocosDenshion::SimpleAudioEngine::getInstance()->playBackgroundMusic("Music/music.wav",true);
}

void Audio::playReadyGo(){
	CocosDenshion::SimpleAudioEngine::getInstance()->playEffect("Music/readygo.wav",false);
}
void Audio::stopBGM()
{
	stop = true;
	CocosDenshion::SimpleAudioEngine::getInstance()->stopBackgroundMusic();
}
void Audio::playPop(){
	CocosDenshion::SimpleAudioEngine::getInstance()->playEffect("Music/pop.wav",false);
}

void Audio::playCombo(int size){
	if(size < 5)
		return;
	if(size >= 10){
		CocosDenshion::SimpleAudioEngine::getInstance()->playEffect("Music/combo_3.wav",false);
	}else if(size >= 7){
		CocosDenshion::SimpleAudioEngine::getInstance()->playEffect("Music/combo_2.wav",false);
	}else {
		CocosDenshion::SimpleAudioEngine::getInstance()->playEffect("Music/combo_1.wav",false);
	}
}
void Audio::prepare(){
	CocosDenshion::SimpleAudioEngine::getInstance()->preloadBackgroundMusic("Music/music.wav");
	CocosDenshion::SimpleAudioEngine::getInstance()->preloadEffect("Music/readygo.wav");
	CocosDenshion::SimpleAudioEngine::getInstance()->preloadEffect("Music/pop.wav");
	CocosDenshion::SimpleAudioEngine::getInstance()->preloadEffect("Music/combo_1.wav");
	CocosDenshion::SimpleAudioEngine::getInstance()->preloadEffect("Music/combo_2.wav");
	CocosDenshion::SimpleAudioEngine::getInstance()->preloadEffect("Music/combo_3.wav");
}